package hotciv.view;

import hotciv.framework.*;

/** Constants to be accessible by all graphics handling abstractions and
 * coordination mappings.
<#if type == "code">

<#include "/data/author.txt">
</#if>
*/

public class GfxConstants {
  // The size of the tile images used, in pixels
  public final static int TILESIZE = 30;
  // Offset the world map by these x and y values in pixels
  public final static int MAP_OFFSET_X = 0;
  public final static int MAP_OFFSET_Y = 0;
  // When drawing the population size number on top of
  // the city graphics, offset this x,y in pixels from
  // top left corner of tile
  public final static int CITY_SIZE_OFFSET_X = 8;
  public final static int CITY_SIZE_OFFSET_Y = 24;
  // When drawing units, this Y offset is subtracted to position their
  // 'feet' on the tile
  public final static int UNIT_OFFSET_Y = 0;
  
  /** return the x pixel position on the graphical display
   * for a tile's column position
   * @param column the position of the tile
   * @return the pixel x coordinate corresponding to column
   */
  public static int getXFromColumn( int column ) {
    return column * TILESIZE + MAP_OFFSET_X;
  }
  /** return the y pixel position on the graphical display
   * for a tile's row position
   * @param row the position of the tile
   * @return the pixel y coordinate corresponding to row
   */
  public static int getYFromRow( int row ) {
    return row * TILESIZE + MAP_OFFSET_Y;
  }
  
  /** return a Game Position for a given (x,y) coordinate
   * on a the MapView used to draw the tiles in MiniDraw
   * @param x the x coordinate
   * @param y the y coordinate
   * @return the position of the tile under (x,y) on the
   * graphical view.
   */
  public static Position getPositionFromXY( int x, int y ) {
    return new Position( (y - MAP_OFFSET_Y) / TILESIZE, 
        (x - MAP_OFFSET_X) / TILESIZE );
  }
  
}
